import { request } from '@/service/request';

/** 获取可用剧本列表 */
export function fetchGetOutboundScriptList() {
  return request<Api.Outbound.Script[]>({
    url: '/outbound/script/list',
    method: 'get'
  });
}

/** 获取剧本详情 */
export function fetchGetOutboundScript(scriptId: string) {
  return request<Api.Outbound.Script>({
    url: `/outbound/script/${scriptId}`,
    method: 'get'
  });
}

/** 创建剧本 */
export function fetchCreateOutboundScript(data: Api.Outbound.CreateScriptParams) {
  return request<boolean>({
    url: '/outbound/script',
    method: 'post',
    data
  });
}

/** 更新剧本 */
export function fetchUpdateOutboundScript(data: Api.Outbound.UpdateScriptParams) {
  return request<boolean>({
    url: '/outbound/script',
    method: 'put',
    data
  });
}

/** 删除剧本 */
export function fetchDeleteOutboundScript(scriptIds: string[]) {
  return request<boolean>({
    url: '/outbound/script',
    method: 'delete',
    data: { scriptIds }
  });
}

/** 创建通知剧本 */
export function fetchCreateNotifyBot(data: Api.Outbound.CreateNotifyBotParams) {
  return request<{ script: string }>({
    url: '/outbound/script/notify',
    method: 'post',
    data
  });
}

/** 查询剧本创建状态 */
export function fetchQueryNotifyBotStatus(scriptName: string) {
  return request<{ state: number }>({
    url: `/outbound/script/notify/${scriptName}/status`,
    method: 'get'
  });
}

/** 导出外呼剧本 */
export function fetchExportOutboundScript(params: any) {
  return request<any>({
    url: '/outbound/script/export',
    method: 'post',
    data: params,
    responseType: 'blob'
  });
}
